<?php
class Index extends Controller
{
	
	public function oauth()
	{
		session_start();
		$domain = "http://weiboapply.sinaapp.com/";
		$o = new WeiboOAuth(Config::$WB_AKEY, Config::$WB_SKEY);
		$keys = $o->getRequestToken();
		$_SESSION['keys'] = $keys;
		$aurl = $o->getAuthorizeURL( $keys['oauth_token'] ,TRUE, $domain.'index/index/callback');
		$this->assign('url', $aurl);
		$this->display('oauth.html');
	}
	
	public function callback()
	{
		Util::ajaxReturn(2334, $_REQUEST);
		session_start();
		$o = new WeiboOAuth(Config::$WB_AKEY, Config::$WB_SKEY, $_SESSION['keys']['oauth_token'], $_SESSION['keys']['oauth_token_secret']);
		$last_key = $o->getAccessToken($_REQUEST['oauth_verifier']);
		//weibolist.php
		$c = new WeiboClient( Config::$WB_AKEY , Config::$WB_SKEY , $last_key['oauth_token'] , $last_key['oauth_token_secret']  );
		$ms  = $c->home_timeline(); // done
		$me = $c->verify_credentials();
		echo $me['name'];
	}
	
	public function Show()
	{
		
	}
	
}